#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <iomanip> 
#include <math.h>
using namespace std;

ifstream  inf("input.txt");              
ofstream  outf("output.txt");


int windo()
{
    int wx,wy;
    wx=500;
    wy=500;
    initwindow(wx,wy);
    moveto(20,0);
    lineto(20,wy);
    moveto(0,wy/2);
    lineto(wx,wy/2);   
    moveto(20,0);
    lineto(15,15);
    moveto(20,0);
    lineto(25,15);
    moveto(wx,wy/2);
    lineto(wx-15,wy/2-5);
    moveto(wx,wy/2);
    lineto(wx-15,wy/2+5);
    moveto(wx-40,wy/2+20);
    outtext("t, sec");
    return wx-40;
}
double rast(double a[60000], int g)
{
         int i;
         double max,min,res;
         max=-1000;
         min=1000;
         for(i=1;i<g;++i)
         {
           if (a[i+1]>a[i] ) max=a[i+1];
           if (a[i+1]<a[i] ) min=a[i+1];
         }
         min=min*(-1);
         if (min>=max) res=min;
         else res=max;
         return 100/res;
}

class nujniy
{

      double a,b,c,T,ht;
      double xo,yo,E;
      double g;
      int nt,i;


public:     
         ~nujniy(void){outf<<"The end!"<<endl;};
      nujniy( double i=0.0,double j=0.0,double k=0.0,double p=0.0, double q=0.0)
       {a=i;b=j;c=k;T=p;ht=q;xo=0.0;yo=0.0;g=9.81;outf<<"Start"<<endl;}
      
      
       double funy(double q, double w)
       {
         double res;
         res=2*(E-(a*w*w*w-b*w+c)*g);
         res=res/(1+(3*a*w*w-b)*(3*a*w*w-b));
         if (res<0) {res=-1.0*res;return sqrt(res);}
         else return sqrt(res);      
       }
       
       double pot(double w)
       {return (a*w*w*w-b*w+c)*g;}

       double proiz(double q)
       {return (3*a*q*q-b);}
       


       void fun_yx(void)
       {
               double fx,x,y;
               int i,u,v;
               
               moveto(500,0);  
               lineto(500,1000);  
               moveto(920,20);
               outtext("Y ( x )");
               moveto(500,0);
               lineto(493,15);
               moveto(500,0);
               lineto(507,15);
               moveto(0,500);
               line(0,500,1000,500);
               moveto(1000,500);
               lineto(985,495);
               moveto(1000,500);
               lineto(985,505);
               moveto(960,520);
               outtext("X, m");
               moveto(520,30);
               outtext("Y, m");
               moveto(500,500);
               for(i=-1500;i<=1500;++i)
               {
                 fx=i*0.01;
                 y=(a*fx*fx*fx-b*fx)*100+500;
                 y=1000-y;
                 fx=fx*100+500;
                 if (i==-150) setcolor(0);
                 else setcolor(15);
                 u=fx; v=y;
                 lineto(u,v);
               }
       }
       void minimum (void)
       {
         double h,fx,miny[30000],mm;
         int i;
         
         h=0.001;
         c=0.0;
         for(i=-12000;i<=12000;++i)
         {
           fx=i*h;
           miny[i+12000]=a*fx*fx*fx-b*fx+c;  
         }
         for(i=0;i<=23999;++i)
         {
           if ((miny[i]<miny[i-1])&&(miny[i+1]>miny[i])) mm=miny[i];
         }
         c=c+(-1)*mm;
         yo=yo+(-1)*mm;
         E=g*yo;
       }
       
       void grand_finale(void)
       {
          double t,nt,k1,k2,k3,k4,dx;
          int i,k;
          double kx,ky;
          int u,v;
          double x[60000],vx[60000],ax[60000];
          t=0.0;
          x[1]=xo+0.000001;
          k=1;
          nt=T/ht;
          outf<<"nt="<<nt<<endl;
          for (i=1;i<=nt;++i)
          {
              k1=ht*funy(t,x[i]);
              k2=ht*funy(t+ht/2.0,x[i]+k1/2.0);
              k3=ht*funy(t+ht/2.0,x[i]+k2/2.0);
              k4=ht*funy(t+ht,x[i]+k3);
              dx=(k1+2.0*k2+2.0*k3+k4)/6.0;
              dx=k*dx;
              if (pot(x[i]+dx)>E) k=k*(-1);  
            x[i+1]=x[i]+dx;
            vx[i]=dx/ht; 
            if (i>=2) ax[i]=(vx[i]-vx[i-1])/ht;
            t+=ht;
          }   
          
            moveto(windo(),20);
            outtext("X ( t )");
            moveto(40,25);
            outtext("X , m");
            moveto(20,250);
            ky=rast(x,nt);
            kx=ht*100;
            while (ky>200){ky=ky/2;}
            for(i=1;i<=nt;++i)
            { 
              v=((x[i])*(-ky)+250);
              u=(i*kx+20);
              lineto(u,v);
            }
            
            moveto(windo(),20);
            outtext("Vx ( t )");
            moveto(40,25);
            outtext("Vx , m/sec");
            moveto(20,250);
            ky=rast(vx,nt)/2;
            while (ky>200){ky=ky/2;}
            for(i=1;i<=nt;++i)
            { 
              v=(vx[i]*(-ky)+250);
              u=i*kx+20;
              lineto(u,v);
            }
            
            moveto(windo(),20);
            outtext("Ax ( t )");
            moveto(40,25);
            outtext("Ax , m/sec^2");
            moveto(20,250);
            ky=10;
            for(i=1;i<=nt;++i)
            { 
               v=(g*proiz(x[i])/(1+proiz(x[i])*proiz(x[i])))*(ky)+250;   
               u=i*kx+20;
               lineto(u,v);
            } 
       }
       

};


main()
{
   initwindow(1000,700); 
   double i,j,k,p,q;
   inf>>i;
   inf>>j;
   inf>>k;
   inf>>p;
   inf>>q;
   
   nujniy post(i,j,k,p,q);
   post.fun_yx();
   post.minimum();
   post.grand_finale();

   getch();
   closegraph();
}
